from BaseView import BaseWebView, BaseWebViewDelegate, BaseWebViewDelegateBuilder, BaseWebViewLeafDelegate
from BaseControl import WebFindKey

class WebListViewDelegateBuilder(BaseWebViewDelegateBuilder):
    def __init__(self, itemFindHandler=(WebFindKey.TAG_NAME, "span"), itemDelegateCls=BaseWebViewLeafDelegate):
        class WebListViewRootDelegate(BaseWebViewDelegate):
            def __init__(self, handler, index, childBuilder):
                super(WebListViewRootDelegate, self).__init__(handler, index, childBuilder)

            def _childHandler(self):
                return itemFindHandler
        super(WebListViewDelegateBuilder, self).__init__(WebListViewRootDelegate, itemDelegateCls)


class WebListView(BaseWebView):
    def __init__(self, handler, delegateBuilder=WebListViewDelegateBuilder()):
        super(WebListView, self).__init__(handler, delegateBuilder)

